import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/view/Index'
import { resolve } from 'url';
import { resolveObject } from 'url';

Vue.use(Router)

const router = new Router({
    base: '/tide/',
    routes: [{
        path: '/',
        name: 'index',
        component: Index
    },
    {
        path: '/home',
        name: 'home',
        component: resolve => require(['@/view/Home.vue'], resolve),
        children: [

            {
                path: '/addCar',
                name: '新增车辆',
                component: resolve => require(['@/view/car/AddCar.vue'], resolve)
            },
            {
                path: '/carList',
                name: '车辆列表',
                component: resolve => require(['@/view/car/CarList.vue'], resolve)
            }
        ]
    }
    ]
})
// router.beforeEach((to, from, next) => {

//     if (to.path == '/') {
//         next()
//     } else {
//         if (menus.length > 0) {
//             next()
//         } else {
//             next('/')
//         }
//     }
// })

export default router